﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;

using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>Initializes business objects of classes derived from the specified base class based on values stored in the entity's subtype field.</summary>
    public interface IBusinessObjectBuilder<TBusinessObjectBase>
        where TBusinessObjectBase : IBusinessObject
    {
        /// <summary>ID of object (sub)type which are created by current builder. Nulls are allowed and typically indicate that builder creates base class object.</summary>
        object TypeId { get; }

        /// <summary>Creates a new business object.</summary>
        /// <param name="messageSourceCulture">Optional culture used by the object's multilingual message source.</param>
        /// <returns>An instance of base or a derived class.</returns>
        TBusinessObjectBase NewBusinessObject(CultureInfo messageSourceCulture);

        /// <summary>Converts entity to new business object.</summary>
        /// <param name="messageSourceCulture">Optional culture used by the object's multilingual message source.</param>
        /// <param name="dbEntity">Entity whose properties, including entity state, are copied to created business object.</param>
        /// <returns>An instance of base or a derived class.</returns>
        TBusinessObjectBase ConvertToBusinessObject(CultureInfo messageSourceCulture, IEntity dbEntity);
    }
}